<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ include file="/include.inc.jsp"%>

<style>
        
        table thead tr{
            border: 1px solid #ddd;
            background-color: #F9F9F9;
        }
        table thead th{
            height: 30px;
            line-height: 30px;
            font-size: 14px;
            border-top: 1px solid #ddd;
            border-right: 1px solid #ddd;
            border-bottom: 1px solid #ddd;
        }
        table thead th:first-child{
            border-left:1px solid #ddd ;
        }
        table tbody td{
            height: 40px;;
            border-right: 1px solid #ddd;
            border-bottom: 1px solid #ddd;
        }
        table tbody td:first-child{
            border-left: 1px solid #ddd;
        }
        table tbody tr:last-child{
            border-bottom: none;
        }
    </style>

<%-- <div class="bjui-pageHeader">
	<form method="post" id="pagerForm" action="${server}/orders" data-toggle="ajaxsearch" >
		<ul class="bjui-searchBar">
			<li>
				<label class="trtitle01">姓名：</label>
				<input type="text" size="15" name="orders.name" class="form-control" value=""/>
			</li>
			<li>
			 	<button type="submit" class="btn-default" data-icon="search">查询</button>
			</li>
		</ul>
	</form>
</div> --%>

<div class="pageContent bjui-resizeGrid" style="top: 29px; bottom: 28px;">
	<table style="width:100%;height:auto;">
		<thead >
			<tr align="center" style="line-height:10px;padding-top:5px;">
				<th style="padding:5px;" width="40" height="10">订单id</th>
				<th style="padding:5px;" width="40" height="10">姓名</th>
				<th style="padding:5px;" width="100" height="10">号码</th>
				<th style="padding:5px;" width="100" height="10">产品名称</th>
				<th style="padding:5px;" width="40" height="10">价格</th>
				<th style="padding:5px;" width="40" height="10">数量</th>
				<th style="padding:5px;" width="40" height="10">订单状态</th>
				<th style="padding:5px;" width="40" height="10">客户类型</th>
				<th style="padding:5px;" width="100" height="10">留言</th>
				<th style="padding:5px;" width="100" height="10">订单创建日期</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page_orders.result}" var="orders">
				<tr style="line-height:10px;">
					<td title="${orders.id}" style="padding:5px;height:10;">${orders.id}</td>
					<td style="padding:5px;height:10;">${orders.name}</td>
					<td style="padding:5px;height:10;">${orders.mobile}</td>
					<td style="padding:5px;height:10;">${orders.pro_name}</td>
					<td style="padding:5px;height:10;">${orders.price}</td>
					<td style="padding:5px;height:10;">${orders.num}</td>
					<td style="padding:5px;height:10;">
						<c:if test="${orders.state==0}">待审核</c:if>
						<c:if test="${orders.state==1}">待发货</c:if>
						<c:if test="${orders.state==2}">已发货</c:if>
						<c:if test="${orders.state==3}">已签收</c:if>
						<c:if test="${orders.state==4}">已回款</c:if>
						<c:if test="${orders.state==5}">未审过</c:if>
						<c:if test="${orders.state==6}">待联系</c:if>
						<c:if test="${orders.state==7}">已拒收</c:if>
					</td>
					<td style="padding:5px;height:10;">
						<c:if test="${orders.xian==1}">一线</c:if>
						<c:if test="${orders.xain==2}">二线</c:if>
						<c:if test="${orders.xian==3}">三线</c:if>
					</td>
					<td style="padding:5px;height:10;">${orders.remark}</td>
					<td style="padding:5px;height:10;"><fmt:formatDate value="${orders.create_date}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	
	<table style="width:100%;height:auto;border: 1px solid grey;margin-top:50px;">
		<thead>
			<tr style="line-height:10px;" align="center">
				<th style="padding:5px;" width="100">回访内容</th>
				<th style="padding:5px;" width="100">回访者</th>
				<th style="padding:5px;" width="100">回访时间</th>
			</tr>
		</thead>
		<tbody id="orderreturn">
			<c:forEach items="${page_return.result}" var="orders_return">
				<tr>
					<td style="padding:5px;">${orders_return.content}</td>
					<td style="padding:5px;">${orders_return.loginname}</td>
					<td style="padding:5px;"><fmt:formatDate value="${orders_return.create_date}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	
	
	<form style="margin-top:80px;">
		<input type="hidden" name="mobile" id="mobilem" value="${mobile }"/>
		<%-- <input type="text" name="order_return.mobile" id="mobile" value="${mobile }"/> --%>
		<div style="height:100px;">    
	        <table class="table table-condensed table-hover" width="100%">
	             <tbody>
	                 <tr>
	                     <td colspan="2"><label for="j_admin_update_note" class="control-label x105">回访信息</label>
	                         <textarea class="form-control" maxlength="200" cols="50" rows="3" name="order_return.content" id="content"></textarea>
	                     </td>
	                 </tr>
	             </tbody>
	        </table>
		</div>
		<div class="bjui-footBar" style="text-align: center;">
			<ul style="margin-left: 40%">
				<li style="float: left"><div class="buttonActive"><div class="buttonContent"><button  type="button" onclick="saveOrdersReturn()" class="btn-default" data-icon="edit" >确认保存</button></div></div></li>
				<li style="float: left"><div class="button"><div class="buttonContent"><button type="button" id="noreturn" data-icon="close" >取消保存</button></div></div></li>
			</ul>
		</div>
	</form>
	
	
</div>
<script type="text/javascript">
	function saveOrdersReturn(){
		var mobile = $("#mobilem").val();
		var content = $("#content").val();
		if(content==""||content==null){
			alert("回访内容不能为空！");
			return;
		}
		var str = {
			"mobile":mobile,
			"content":content
		};
		$.ajax(''+server+'/orders/saveReturns',{
			dataType:'json',//服务器返回json格式数据
			type:'post',//HTTP请求类型
			data:str,
			timeout:1000,//超时时间设置为10秒；
			success:function(data){
				alert("回访信息填写成功！");
				//window.location.href=server+"/orders/orderList?mobile="+mobile;
				
				var str = '<tr><td style="padding:5px;">'+data.content+'</td><td style="padding:5px;">'+data.loginname+'</td><td style="padding:5px;">'+data.create_date+'</td></tr>';
				$("#orderreturn").append(str);
				$("#content").val("");
			}
		});
	}
	
	$("#noreturn").click(function(){
		$("#content").val("");
		$("#content").text("");
	});
</script>
